package ar.com.spsolutions.splibrary.book;

import org.joda.time.DateTime;

import ar.com.spsolutions.splibrary.entity.Entity;
import ar.com.spsolutions.splibrary.user.User;

public class BookComment extends Entity {
	private static final long serialVersionUID = -1432430853465929767L;

	private static final int COMMENT_SIZE = 500;

	private DateTime timestamp;

	private User user;

	private String text;

	public BookComment() {
		super();
	}

	public void markTimeStamp() {
		this.setTimestamp(new DateTime());
	}

	public BookComment(final User aUser, final String aText) {
		super();
		this.user = aUser;
		this.setText(aText);
	}

	public String getText() {
		return this.text;
	}

	public void setText(final String aText) {
		if (aText.length() > BookComment.COMMENT_SIZE) {
			throw new IllegalArgumentException(//
					"El tamanio maximo del mensaje es de "//
							+ BookComment.COMMENT_SIZE);
		}
		this.text = aText;
	}

	public DateTime getTimestamp() {
		return this.timestamp;
	}

	public void setTimestamp(final DateTime aTimestamp) {
		this.timestamp = aTimestamp;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(final User aUser) {
		this.user = aUser;
	}
}
